

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaarm">
    <el-row>
    <el-col :span="12">
    <!-- {"index":22,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","v","c","u","lw(80)","align(left,l)","DN","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="32" 
      :rows="0"  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":23,"raw":"icon","name":"icon","cname":"Icon","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","v","c","u","tp(icon,l-le)","lidx(102)","align(right,l)"],"desc":{"raw":"图标","name":"图标"}} -->
    <!--图标 输入控件 -->
    <el-form-item prop="icon" label="图标" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.icon"  maxlength="32" 
      :rows="0"  placeholder="请输入图标"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":24,"raw":"menu_type","name":"menu_type","cname":"MenuType","type":{"raw":"tinyint(1)","name":"tinyint","len":1,"dlen":0},"defValue":"0","allowNull":true,"constraints":["bl","v","c","u","sl","tp(radio,c-u)"],"desc":{"raw":"类型 (0默认1菜单2页面)","name":"类型"}} -->
    <el-form-item prop="menu_type" label="类型" label-width="100px" label-position="right">
      <el-radio-group v-model="form.menu_type"   >
        <el-radio-button v-for="item in menu_typeList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
      <el-tooltip raw-content="true" content="类型 (0默认1菜单2页面)" placement="bottom" effect="light">
      <i class="form_item_info fa fa-info-circle"  aria-hidden="true" />
      </el-tooltip>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":25,"raw":"url","name":"url","cname":"Url","type":{"raw":"varchar(255)","name":"varchar","len":255,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","bl","v","c","u","rows(1)"],"desc":{"raw":"地址标识","name":"地址标识"}} -->
    <!--地址标识 输入控件 -->
    <el-form-item prop="url" label="地址标识" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.url"  maxlength="255" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入地址标识"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":26,"raw":"is_open","name":"is_open","cname":"IsOpen","type":{"raw":"tinyint(1)","name":"tinyint","len":1,"dlen":0},"defValue":"0","allowNull":true,"constraints":["v","c","u","bl","sl(bool)","tp(radio,c-u)"],"desc":{"raw":"展开","name":"展开"}} -->
    <el-form-item prop="is_open" label="展开" label-width="100px" label-position="right">
      <el-radio-group v-model="form.is_open"   >
        <el-radio-button v-for="item in is_openList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":27,"raw":"sortrank","name":"sortrank","cname":"Sortrank","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"","allowNull":false,"constraints":["v","bl","c","u","ord(asc)","tp(number,c-u)"],"desc":{"raw":"排序","name":"排序"}} -->
    <!--排序 数字控件 -->
    <el-form-item prop="sortrank" label="排序" label-width="100px" label-position="right">
      <el-input-number 
       :precision="0"  
      
        style="width: 100%" v-model="form.sortrank" />
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":28,"raw":"status","name":"status","cname":"Status","type":{"raw":"tinyint(1)","name":"tinyint","len":1,"dlen":0},"defValue":"0","allowNull":false,"constraints":["l","v","c","u","sl","tp(radio,c-u)","tp(tag,l)"],"desc":{"raw":"状态  0正常 1禁用","name":"状态"}} -->
    <el-form-item prop="status" label="状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.status"   >
        <el-radio-button v-for="item in statusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
      <el-tooltip raw-content="true" content="状态  0正常 1禁用" placement="bottom" effect="light">
      <i class="form_item_info fa fa-info-circle"  aria-hidden="true" />
      </el-tooltip>
    </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改功能菜单",
rules_aaarm:{
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    icon:[{required:false,message:"请输入图标",trigger: 'blur'}],
    menu_type:[{required:false,message:"请输入类型",trigger: 'blur'}],
    url:[{required:true,message:"请输入地址标识",trigger: 'blur'}],
    is_open:[{required:false,message:"请输入展开",trigger: 'blur'}],
    sortrank:[{required:true,message:"请输入排序",trigger: 'blur'}],
    status:[{required:true,message:"请输入状态",trigger: 'blur'}],
  },
    form:{
        name:"",
        icon:"",
        menu_type:"",
        url:"",
        is_open:"",
        sortrank:"",
        status:"",
    },
    menu_typeList:[],
    is_openList:[],
    statusList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaarm()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.id = form.id
        this.$theia.http.get("/sso/system/menu",postForm).then(res=>{
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaarm()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `功能菜单查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/sso/system/menu",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '功能菜单保存成功',duration:5000})
            that.$theia.enum.clear("system_menu")
            that.$theia.enum.get("system_menu")
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `功能菜单修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
    loadEnums_aaarm(){
        //类型
        this.menu_typeList = this.$theia.enum.get("menu_type","","" ,false,"")
        //展开
        this.is_openList = this.$theia.enum.get("bool","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>